package simulation;

import java.util.List;

import util.Location;
import util.Vector;

public class ConstantCenterOfMass extends CenterOfMass{
	
	private static final double DEFAULT_MAGNITUDE = 0.02;
	public ConstantCenterOfMass(){
		this(DEFAULT_MAGNITUDE);
	}
	public ConstantCenterOfMass(double magnitude){
		super(magnitude);
	}
	
	
	public void apply(List<Mass> Masses){
		if (!isOn()) 
			return;
		Location center=calculateCenter(Masses);
		
		for (Mass m:Masses){
			Vector theForce=new Vector(m.getCenter(),center);
			Vector adjustedForce=new Vector(theForce.getDirection(),getMagnitude());
			m.applyForce(adjustedForce);
			
		}
		
		
	}

}
